import { ClientMessage } from "@runtime/generate/message/ClientMessage";
import MessageHandler from "@runtime/module/Handler/MessageHandler";
import ModalComponent, { ModalOptions } from "@runtime/module/Modal/ModalComponent";
import PostProcessLayerComponent from "@runtime/UnityEngineBridge/PostProcessLayerComponent";

export default class IntelligentConnectedVehicleInstallationCompleteMessageHandler extends MessageHandler<ClientMessage.IntelligentConnectedVehicleInstallationCompleteMessage> {
    protected async RunAsync(message: ClientMessage.IntelligentConnectedVehicleInstallationCompleteMessage): Promise<void> {
        const volume = await PostProcessLayerComponent.Default.AddVolumeAsync();
        const effect = await PostProcessLayerComponent.Default.AddKawaseBlurAsync(volume);

        const options = ModalOptions.Default()
            .WithPrefix('/src/components/Apps/Lidar/')
            .WithType('Exit')
            .WithTitle('信息')
            .WithContent('恭喜你，安装任务已完成！')
            .WithButtons(['确定']);
        await ModalComponent.Default.PopupAsync(options);

        await PostProcessLayerComponent.Default.RemoveEffectAsync(volume, effect);
        await PostProcessLayerComponent.Default.RemoveVolumeAsync(volume);
    }
}